package com.weihui.jxc.view.customer;

import javax.swing.JPanel;
import java.awt.GridLayout;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import javax.swing.JTextField;

import com.weihui.jxc.common.CommonFactory;
import com.weihui.jxc.common.ValidationManager;
import com.weihui.jxc.model.Customer;
import com.weihui.jxc.model.Operator;
import com.weihui.jxc.service.CustomerService;
import com.weihui.jxc.view.CustomerInternalFrame;
import com.weihui.jxc.view.LoginFrame;

import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.FlowLayout;
import javax.swing.JButton;
import java.awt.Color;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.ImageIcon;

/**
 * 客户信息添加面板
 * 
 * @author xiaowie
 *
 */
public class CustormerAddPanel extends JPanel implements ActionListener {
	private JTextField customerNameTf;
	private JTextField addressTf;
	private JTextField shortsTf;
	private JTextField zipTf;
	private JTextField telTf;
	private JTextField faxTf;
	private JTextField contactsTf;
	private JTextField phoneTf;
	private JTextField emailTf;
	private JTextField bankTf;
	private JTextField accountTf;
    private CustomerService customerService =  null;
    
    public static Operator operator = null;//保存登录后的数据
	/**
	 * Create the panel.
	 */
	public CustormerAddPanel() {
		setBackground(new Color(238, 238, 238));

		JPanel panel = new JPanel();

		JLabel lblNewLabel = new JLabel("客户全称：");
		lblNewLabel.setIcon(new ImageIcon(CustormerAddPanel.class.getResource("/images/客户图标.png")));
		panel.add(lblNewLabel);

		customerNameTf = new JTextField();
		panel.add(customerNameTf);
		customerNameTf.setColumns(25);

		JLabel label_9 = new JLabel("");

		JLabel label = new JLabel("");

		JPanel panel_1 = new JPanel();

		JLabel lblNewLabel_1 = new JLabel("客户地址：");
		lblNewLabel_1.setIcon(new ImageIcon(CustormerAddPanel.class.getResource("/images/地址.png")));
		panel_1.add(lblNewLabel_1);

		addressTf = new JTextField();
		panel_1.add(addressTf);
		addressTf.setColumns(30);

		JLabel label_10 = new JLabel("");

		JLabel label_11 = new JLabel("");

		JLabel label_12 = new JLabel("");

		JLabel label_13 = new JLabel("");

		JLabel label_14 = new JLabel("");

		JLabel label_15 = new JLabel("");

		JPanel panel_2 = new JPanel();

		JLabel lblNewLabel_2 = new JLabel("客户简称：");
		lblNewLabel_2.setIcon(new ImageIcon(CustormerAddPanel.class.getResource("/images/简称.png")));
		panel_2.add(lblNewLabel_2);

		shortsTf = new JTextField();
		panel_2.add(shortsTf);
		shortsTf.setColumns(25);

		JLabel label_16 = new JLabel("");

		JLabel label_1 = new JLabel("");

		JPanel panel_3 = new JPanel();

		JLabel lblNewLabel_3 = new JLabel("客户邮编：");
		lblNewLabel_3.setIcon(new ImageIcon(CustormerAddPanel.class.getResource("/images/邮编.png")));
		panel_3.add(lblNewLabel_3);

		zipTf = new JTextField();
		panel_3.add(zipTf);
		zipTf.setColumns(30);

		JLabel label_17 = new JLabel("");

		JLabel label_18 = new JLabel("");

		JLabel label_19 = new JLabel("");

		JLabel label_20 = new JLabel("");

		JLabel label_21 = new JLabel("");

		JLabel label_22 = new JLabel("");

		JPanel panel_4 = new JPanel();

		JLabel lblNewLabel_4 = new JLabel("客户电话：");
		lblNewLabel_4.setIcon(new ImageIcon(CustormerAddPanel.class.getResource("/images/电  话.png")));
		panel_4.add(lblNewLabel_4);

		telTf = new JTextField();
		panel_4.add(telTf);
		telTf.setColumns(25);

		JPanel panel_5 = new JPanel();

		JLabel lblNewLabel_5 = new JLabel("传    真：");
		lblNewLabel_5.setIcon(new ImageIcon(CustormerAddPanel.class.getResource("/images/传真.png")));
		panel_5.add(lblNewLabel_5);

		faxTf = new JTextField();
		panel_5.add(faxTf);
		faxTf.setColumns(30);

		JLabel label_23 = new JLabel("");

		JLabel label_24 = new JLabel("");

		JLabel label_25 = new JLabel("");

		JLabel label_26 = new JLabel("");

		JLabel label_27 = new JLabel("");

		JLabel label_28 = new JLabel("");

		JLabel label_2 = new JLabel("");

		JLabel label_29 = new JLabel("");

		JPanel panel_6 = new JPanel();

		JLabel lblNewLabel_6 = new JLabel("联 系 人：");
		lblNewLabel_6.setIcon(new ImageIcon(CustormerAddPanel.class.getResource("/images/联系人.png")));
		panel_6.add(lblNewLabel_6);

		contactsTf = new JTextField();
		panel_6.add(contactsTf);
		contactsTf.setColumns(25);

		JLabel label_30 = new JLabel("");

		JLabel label_3 = new JLabel("");

		JPanel panel_7 = new JPanel();

		JLabel lblNewLabel_7 = new JLabel("联系电话：");
		lblNewLabel_7.setIcon(new ImageIcon(CustormerAddPanel.class.getResource("/images/电  话.png")));
		panel_7.add(lblNewLabel_7);

		phoneTf = new JTextField();
		panel_7.add(phoneTf);
		phoneTf.setColumns(30);

		JLabel label_31 = new JLabel("");

		JLabel label_32 = new JLabel("");

		JLabel label_33 = new JLabel("");

		JLabel label_34 = new JLabel("");

		JLabel label_35 = new JLabel("");

		JLabel label_36 = new JLabel("");

		JPanel panel_8 = new JPanel();

		JLabel lblNewLabel_8 = new JLabel("客户邮箱：");
		lblNewLabel_8.setIcon(new ImageIcon(CustormerAddPanel.class.getResource("/images/邮箱.png")));
		panel_8.add(lblNewLabel_8);

		emailTf = new JTextField();
		panel_8.add(emailTf);
		emailTf.setColumns(64);

		JLabel label_37 = new JLabel("");

		JLabel label_38 = new JLabel("");

		JLabel label_39 = new JLabel("");

		JLabel label_40 = new JLabel("");

		JLabel label_41 = new JLabel("");

		JLabel label_42 = new JLabel("");

		JLabel label_4 = new JLabel("");

		JLabel label_43 = new JLabel("");

		JLabel label_5 = new JLabel("");

		JPanel panel_9 = new JPanel();

		JPanel panel_10 = new JPanel();
		panel_9.add(panel_10);

		JLabel lblNewLabel_9 = new JLabel("开户银行：");
		lblNewLabel_9.setIcon(new ImageIcon(CustormerAddPanel.class.getResource("/images/银行.png")));
		panel_10.add(lblNewLabel_9);

		bankTf = new JTextField();
		panel_10.add(bankTf);
		bankTf.setColumns(25);

		JLabel label_44 = new JLabel("");

		JLabel label_45 = new JLabel("");

		JLabel label_6 = new JLabel("");

		JPanel panel_11 = new JPanel();

		JLabel lblNewLabel_10 = new JLabel("银行账户：");
		lblNewLabel_10.setIcon(new ImageIcon(CustormerAddPanel.class.getResource("/images/账户.png")));
		panel_11.add(lblNewLabel_10);

		accountTf = new JTextField();
		panel_11.add(accountTf);
		accountTf.setColumns(30);

		JLabel label_46 = new JLabel("");

		JLabel label_47 = new JLabel("");

		JLabel label_48 = new JLabel("");

		JLabel label_49 = new JLabel("");

		JLabel label_50 = new JLabel("");

		JPanel panel_12 = new JPanel();

		JButton saveBtn = new JButton("保存");
		saveBtn.setIcon(new ImageIcon(CustormerAddPanel.class.getResource("/images/修 改.png")));
		saveBtn.addActionListener(this);
		panel_12.add(saveBtn);

		JButton resetBtn = new JButton("重置");
		resetBtn.setIcon(new ImageIcon(CustormerAddPanel.class.getResource("/images/重置.png")));
		resetBtn.addActionListener(this);
		panel_12.add(resetBtn);

		JLabel label_51 = new JLabel("");

		JLabel label_52 = new JLabel("");

		JLabel label_53 = new JLabel("");

		JLabel label_54 = new JLabel("");

		JLabel label_7 = new JLabel("");

		JLabel label_8 = new JLabel("");

		JLabel label_55 = new JLabel("");

		JLabel label_56 = new JLabel("");

		JLabel label_57 = new JLabel("");
		GroupLayout groupLayout = new GroupLayout(this);
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addGap(12)
					.addComponent(panel_6, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
					.addGap(5)
					.addComponent(label_30)
					.addGap(5)
					.addComponent(label_3)
					.addGap(419)
					.addComponent(label_31)
					.addGap(5)
					.addComponent(label_32)
					.addGap(5)
					.addComponent(label_33)
					.addGap(5)
					.addComponent(label_34)
					.addGap(5)
					.addComponent(label_35))
				.addGroup(groupLayout.createSequentialGroup()
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addGroup(groupLayout.createSequentialGroup()
							.addContainerGap()
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addGroup(groupLayout.createSequentialGroup()
									.addComponent(panel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
									.addGap(5)
									.addComponent(label_9)
									.addGap(5)
									.addComponent(label))
								.addGroup(groupLayout.createSequentialGroup()
									.addComponent(panel_2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
									.addGap(5)
									.addComponent(label_16)
									.addGap(5)
									.addComponent(label_1))))
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(15)
							.addComponent(panel_4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
					.addGap(105)
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addComponent(panel_5, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addGroup(groupLayout.createSequentialGroup()
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addGroup(groupLayout.createSequentialGroup()
									.addComponent(panel_3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
									.addPreferredGap(ComponentPlacement.RELATED)
									.addComponent(label_17)
									.addGap(5)
									.addComponent(label_18)
									.addGap(5)
									.addComponent(label_19)
									.addGap(5)
									.addComponent(label_20)
									.addGap(5)
									.addComponent(label_21))
								.addComponent(panel_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
							.addGap(395)
							.addComponent(label_10)
							.addGap(5)
							.addComponent(label_11)
							.addGap(5)
							.addComponent(label_12)
							.addGap(5)
							.addComponent(label_13)
							.addGap(5)
							.addComponent(label_14))
						.addGroup(groupLayout.createSequentialGroup()
							.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
								.addComponent(panel_11, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addGroup(groupLayout.createSequentialGroup()
									.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
										.addComponent(panel_7, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
										.addComponent(label_23))
									.addGap(5)
									.addComponent(label_24)
									.addGap(5)
									.addComponent(label_25)))
							.addGap(5)
							.addComponent(label_26)
							.addGap(5)
							.addComponent(label_27)
							.addGap(5)
							.addComponent(label_28)
							.addGap(5)
							.addComponent(label_2))))
				.addGroup(groupLayout.createSequentialGroup()
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(330)
							.addComponent(label_51)
							.addGap(414)
							.addComponent(label_52)
							.addGap(5)
							.addComponent(label_53)
							.addGap(5)
							.addComponent(label_54)
							.addGap(5)
							.addComponent(label_7))
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(4)
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(panel_8, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addGroup(groupLayout.createSequentialGroup()
									.addComponent(label_43)
									.addGap(5)
									.addComponent(label_5)
									.addGap(5)
									.addComponent(panel_9, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))))
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(5)
							.addComponent(label_37)
							.addGap(5)
							.addComponent(label_38)
							.addGap(5)
							.addComponent(label_39)
							.addGap(5)
							.addComponent(label_40)
							.addGap(5)
							.addComponent(label_41)
							.addGap(5)
							.addComponent(label_42))
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(5)
							.addComponent(label_44)
							.addGap(5)
							.addComponent(label_45)
							.addGap(5)
							.addComponent(label_6)
							.addGap(419)
							.addComponent(label_46)
							.addGap(5)
							.addComponent(label_47)
							.addGap(5)
							.addComponent(label_48)
							.addGap(5)
							.addComponent(label_49))
						.addGroup(groupLayout.createSequentialGroup()
							.addComponent(label_8)
							.addGap(5)
							.addComponent(label_55)
							.addGap(5)
							.addComponent(label_56))))
				.addGroup(groupLayout.createSequentialGroup()
					.addGap(375)
					.addComponent(panel_12, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addGap(5)
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addComponent(panel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(16)
							.addComponent(label_9))
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(16)
							.addComponent(label))
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(16)
							.addComponent(label_10))
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(16)
							.addComponent(label_11))
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(16)
							.addComponent(label_12))
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(16)
							.addComponent(label_13))
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(16)
							.addComponent(label_14))
						.addComponent(panel_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(ComponentPlacement.RELATED)
					.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
						.addGroup(groupLayout.createSequentialGroup()
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(panel_2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(16)
									.addComponent(label_16))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(16)
									.addComponent(label_1))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(16)
									.addComponent(label_17))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(16)
									.addComponent(label_18))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(16)
									.addComponent(label_19))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(16)
									.addComponent(label_20))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(16)
									.addComponent(label_21)))
							.addGap(5))
						.addGroup(groupLayout.createSequentialGroup()
							.addComponent(panel_3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
							.addGap(18)))
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addComponent(panel_4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(16)
							.addComponent(label_24))
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(16)
							.addComponent(label_25))
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(16)
							.addComponent(label_26))
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(16)
							.addComponent(label_27))
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(16)
							.addComponent(label_28))
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(16)
							.addComponent(label_2))
						.addGroup(groupLayout.createSequentialGroup()
							.addPreferredGap(ComponentPlacement.RELATED)
							.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
								.addComponent(panel_5, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(label_23))))
					.addGap(5)
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addGroup(groupLayout.createSequentialGroup()
							.addComponent(panel_7, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
							.addGap(49)
							.addComponent(panel_11, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
						.addGroup(groupLayout.createSequentialGroup()
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(panel_6, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(16)
									.addComponent(label_30))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(16)
									.addComponent(label_3))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(16)
									.addComponent(label_31))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(16)
									.addComponent(label_32))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(16)
									.addComponent(label_33))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(16)
									.addComponent(label_34))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(16)
									.addComponent(label_35)))
							.addGap(5)
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(panel_8, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(16)
									.addComponent(label_37))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(16)
									.addComponent(label_38))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(16)
									.addComponent(label_39))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(16)
									.addComponent(label_40))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(16)
									.addComponent(label_41))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(16)
									.addComponent(label_42)))
							.addGap(5)
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(21)
									.addComponent(label_43))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(21)
									.addComponent(label_5))
								.addComponent(panel_9, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(21)
									.addComponent(label_44))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(21)
									.addComponent(label_45))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(21)
									.addComponent(label_6))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(21)
									.addComponent(label_46))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(21)
									.addComponent(label_47))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(21)
									.addComponent(label_48))
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(32)
									.addComponent(label_49)))
							.addGap(24)
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(label_51)
								.addComponent(label_52)
								.addComponent(label_53)
								.addComponent(label_54)
								.addComponent(label_7)
								.addComponent(label_8)
								.addComponent(label_55)
								.addComponent(label_56)
								.addComponent(panel_12, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
					.addGap(44))
		);
		setLayout(groupLayout);
        //初始化service
		customerService = CommonFactory.getCustomerService();
	}
    /**
     * 监听点击事件
     */
	@Override
	public void actionPerformed(ActionEvent e) {
		String target = e.getActionCommand();
		switch (target) {
		case "保存":
			//格式校验
		Boolean isTrue=	CustomerInternalFrame.dataCheck(customerNameTf.getText().trim(),
					addressTf.getText().trim(),
					shortsTf.getText().trim(),
					zipTf.getText().trim(),
					telTf.getText().trim(),
					faxTf.getText().trim(),
					contactsTf.getText().trim(),
					phoneTf.getText().trim(),
					emailTf.getText().trim(),
					bankTf.getText().trim(),
					accountTf.getText().trim());
	//isTrue = false;
	if(isTrue == true) {
				//获取客户编号
			String id = customerService.getCustomerId();
			//将客户信息添加到数据库
			Customer customer = new Customer(id, customerNameTf.getText().trim(), 
					shortsTf.getText().trim(), addressTf.getText().trim(), 
					zipTf.getText().trim(), telTf.getText().trim(), 
					faxTf.getText().trim(), contactsTf.getText().trim(), 
					phoneTf.getText().trim(), bankTf.getText().trim(), 
					accountTf.getText().trim(), emailTf.getText().trim(), 1);
			boolean result = customerService.addCustomer(customer);
			if(result==true) {
				JOptionPane.showMessageDialog(null, "客户信息添加成功！","提示",JOptionPane.INFORMATION_MESSAGE);
				setNull();
			}else {
				JOptionPane.showMessageDialog(null, "客户信息添加失败！","警告",JOptionPane.WARNING_MESSAGE);			
			}
			break;
		}else {
			JOptionPane.showMessageDialog(null, "填写的数据非法，请认真检查！","警告",JOptionPane.WARNING_MESSAGE);
		}
				
		case "重置":
			setNull();
			
			break;
		default:
			break;
		}

	}
	
	/**
	 * 清空文本框中的值
	 */
	private void setNull() {
		customerNameTf.setText("");
		shortsTf.setText("");
		addressTf.setText("");
		zipTf.setText("");
		telTf.setText("");
		faxTf.setText("");
		contactsTf.setText("");
		phoneTf.setText("");
		bankTf.setText("");
		accountTf.setText("");
		emailTf.setText("");
	}
}